import java.util.Scanner;
import java.util.Stack;
import java.util.Arrays;

public class a017 {
	public static int operatorCalculation(char operator, int top, int under) {
		int currentSummation = 0;
		
		if(operator == '+')
			{ currentSummation = under + top;	}
		else if(operator == '-')
			{ currentSummation = under - top; }
		else if(operator == '*')
			{ currentSummation = under * top; }
		else if(operator == '/')
			{ currentSummation = under / top; }
		else
			{ currentSummation = under % top; }
		
		return currentSummation;
	}
	public static String result(String[] postfix) {
		int summation = 0;
		Stack<Integer> operandStack = new Stack<Integer> ();
		int top, under;
		
		for(int i = 0; i < postfix.length; i++) {
			char[] tokenDetermine = postfix[i].toCharArray();
			
			if(isOperator(tokenDetermine[0])) {
				top = operandStack.pop();
				under = operandStack.pop();
				
				operandStack.push(operatorCalculation(tokenDetermine[0], top, under));
				
				if(i == (postfix.length - 1))
					{ summation = operandStack.pop(); }
			} else {
				operandStack.push(Integer.parseInt(postfix[i]));
			}
		}
		
		return Long.toString(summation);
	}
	public static int priorities(char operator) {
		if(operator == '(')
			{ return 2; }
		else if(operator == '*' || operator == '/' || operator == '%')
			{ return 0;	}
		else
			{ return 1; }
	}
	public static String[] transform(String[] infix) {
		String[] tempPostfix = new String[postfixLength];
		Arrays.fill(tempPostfix, "");
		Stack<String> tokensStack = new Stack<String>();

		int token = 0;
		for(int i = 0; i < infix.length; i++) {
			char[] tokenDetermine = infix[i].toCharArray();

			if(isOperator((tokenDetermine[0]))) {				
				// 遇到')'彈出堆疊內運算子，直到遇到堆疊內'('，兩者互相抵銷
				if(tokenDetermine[0] == ')') {
					char[] topOperator = tokensStack.peek().toCharArray();
					
					while(topOperator[0] != '(') {
						tempPostfix[token] = tokensStack.pop();
						token ++;
						
						topOperator = tokensStack.peek().toCharArray();
					}
					tokensStack.pop();
					continue;
				}
				
				if(tokensStack.isEmpty()) {
					tokensStack.push(infix[i]);
				} else {
					char[] topOperator = tokensStack.peek().toCharArray();
					if(priorities(tokenDetermine[0]) < priorities(topOperator[0])) {
						tokensStack.push(infix[i]);
					} else {
						if(tokenDetermine[0] == '(') {
							tokensStack.push(infix[i]);
						} else {
							tempPostfix[token] = tokensStack.pop();
							token ++;
							
							if(!(tokensStack.isEmpty())) {
								topOperator = tokensStack.peek().toCharArray();
								while(priorities(tokenDetermine[0]) == priorities(topOperator[0])) {								
									tempPostfix[token] = tokensStack.pop();
									token ++;
									
									if(!(tokensStack.isEmpty())) {
										topOperator = tokensStack.peek().toCharArray();
									} else {
										break;
									}
								}
							}

							tokensStack.push(infix[i]);
						}
					}
				}
			} else {
				tempPostfix[token] = infix[i];
				token ++;
			}
		}
		// 堆疊內剩餘的運算子
		while(!(tokensStack.isEmpty())) {
			tempPostfix[token] = tokensStack.pop();
			token ++;
		}
		
		return tempPostfix;
	}
	public static int postfixLength;
	public static boolean isOperator(char c) { // c = eachInputCharacter
		if(c == '(' ||
				c == ')' ||
					c == '+' ||
						c == '-' ||
							c == '*' ||
								c == '/' ||
									c == '%') {
			return true;
		} else {
			return false;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String input, output;
		int m;
		
		// 輸入測資且執行
		while(sc.hasNext()) {
			input = sc.nextLine();

			// 中置運算式
			String[] infix = input.split(" ");
			
			// 測量後置運算式長度
			postfixLength = infix.length;
			for(String str : infix) {
				char[] operatorDetermine = str.toCharArray();

				if(operatorDetermine[0] == '(' || operatorDetermine[0] == ')')
					{ postfixLength --; }
			}
			
			// 後置運算式陣列
			String[] postfix = Arrays.copyOf(transform(infix), postfixLength);

//			System.out.println("Postfix is " + Arrays.toString(postfix));
			
			System.out.println(result(postfix));
		} //next
	} // main
}